package org.bookie.core.services;

import java.io.IOException;

import org.bookie.core.model.FacebookUser;

import com.facebook.api.FacebookException;
import com.facebook.api.FacebookXmlRestClient;

/**
 * Convenience wrapper around {@link FacebookXmlRestClient} to simplify hivemind/tapestry
 * integration
 * 
 * @author zubairov
 */
public interface IFacebookClient {

	/**
	 * Authenticate given {@link IFacebookClient} with given auth token.
	 * 
	 * This is the first method that needs to be called when using {@link IFacebookClient}
	 * 
	 * @param token
	 * @throws FacebookException - in case secret key is not found in env or any other facebook exception 
	 * @throws IOException 
	 */
	void authenticate(String token) throws FacebookException, IOException;

	/**
	 * Returns an ID of the user who is authenticated inside the session
	 * @return
	 * @throws IOException 
	 * @throws FacebookException 
	 */
	int getAuthenticatedUserID() throws FacebookException, IOException;

	/**
	 * Returns a authenticated user
	 * @throws IOException 
	 * @throws FacebookException 
	 */
	FacebookUser getAuthenticatedUser() throws FacebookException, IOException;

	/**
	 * Returns true in case current user has a Facebook authentication/session
	 * 
	 * @return
	 */
	boolean isAuthenticated();

	/**
	 * Publishes action with given title and body
	 * 
	 * @param title
	 * @param body
	 * @throws IOException 
	 * @throws FacebookException 
	 */
	boolean publishAction(String title, String body) throws FacebookException, IOException;
	
}
